#include				"ApiAudio.h"
#include				"audio.h"

ApiAudio::ApiAudio(Audio * audio) : _manager(audio)
{

}

ApiAudio::~ApiAudio()
{

}

void					ApiAudio::setVolume(float volume)
{
	_manager->_speaker.setVolume(volume);
}

void					ApiAudio::decode(Packet *input, SoundPacket *output, unsigned int id)
{
  _manager->_decoder.decode(input, output, id);
}

void					ApiAudio::newBuffer(unsigned int id)
{
  _manager->_decoder.addState(id);
  _manager->_speaker.newBuffer(id);
  std::cout << "[INFO] Allocating buffer for id " << id << std::endl;
}

void					ApiAudio::destroyBuffer(unsigned int id)
{
  _manager->_decoder.removeState(id);
  _manager->_speaker.destroyBuffer(id);
  std::cout << "[INFO] Deleting buffer for id " << id << std::endl;
}

SoundPacket				*ApiAudio::getPacket(unsigned int id)
{
  return (_manager->_speaker.getSoundPacket(id));
}

void					ApiAudio::packetReady(unsigned int id)
{
  _manager->_speaker.packetReady(id);
}
